#include "prpdspectrum.h"
#include "private/prpsprpdspectrumprivatedefine.h"
#include "common/dataspecificationutils.h"
#include "common/binaryprocesshelper.h"
#include "common/xmldocument.h"
#include "private/spectrumdatafilecommondefine.h"
#include "common/xmlprocesshelper.h"
#include <QDebug>

namespace DataSpecificationGW
{
    class PRPDSpectrumPrivate
    {
    public:
        PRPDExtInformationPrivate m_stPRPDExtInformationPrivate;
        PRPDDataPrivate m_stPRPDDataPrivate;
    };

    PRPDSpectrum::PRPDSpectrum()
        : Spectrum(),
          m_pPRPDSpectrumPrivate(new PRPDSpectrumPrivate)
    {
    }

    PRPDSpectrum::~PRPDSpectrum()
    {
    }

    /************************************************
     * 函数名   : setDataSpecificationVersion
     * 输入参数 :
       const DataSpecificationVersion eDataSpecificationVersion: 数据规范版本号
     * 输出参数 : NULL
     * 返回值   : void
     * 功能     : 设置数据规范版本号
     ************************************************/
    void PRPDSpectrum::setDataSpecificationVersion(const DataSpecificationVersion eDataSpecificationVersion)
    {
        Spectrum::setDataSpecificationVersion(eDataSpecificationVersion);
        if (V_1_1_0_0 == eDataSpecificationVersion)
        {
            m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.skipDataJudgmentFlag();
            m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.skipGain();
            m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.skipSyncSource();
            m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.skipSyncState();
            m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.skipSyncFrequency();
            m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.skipDischargeSeverity();
            m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.skipDenoisingThreshold();
        }
        else if (V_4_1_0_2 == eDataSpecificationVersion)
        {
            m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.skipBGFileName();
            m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.skipDenoisingThreshold();
        }
    }

    /************************************************
     * 函数名   : spectrumName
     * 输入参数 : NULL
     * 输出参数 : NULL
     * 返回值   : QString
     * 功能     : 图谱名称
     ************************************************/
    QString PRPDSpectrum::spectrumName() const
    {
        return STR_FILE_NODE_PRPD;
    }

    /************************************************
     * 函数名   : setPRPDExtInformation
     * 输入参数 :
       const PRPDExtInformation& stPRPDExtInformation: PRPDExtInformation
     * 输出参数 : NULL
     * 返回值   : void
     * 功能     : 设置PRPDExtInformation
     ************************************************/
    void PRPDSpectrum::setPRPDExtInformation(const PRPDExtInformation& stPRPDExtInformation)
    {
        m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucAmpUnit = stPRPDExtInformation.eAmpUnit;
        m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.fAmpLowerLimit = stPRPDExtInformation.fAmpLowerLimit;
        m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.fAmpUpperLimit = stPRPDExtInformation.fAmpUpperLimit;
        m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucFrequencyBand = stPRPDExtInformation.eFrequencyBand;
        m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.fFrequencyLowerLimit = stPRPDExtInformation.fFrequencyLowerLimit;
        m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.fFequencyUpperLimit = stPRPDExtInformation.fFequencyUpperLimit;
        m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.iPhaseWindowCount = stPRPDExtInformation.iPhaseWindowCount;
        m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.iQuantizedAmplitude = stPRPDExtInformation.iQuantizedAmplitude;
        m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.iPowerFreqCycleCount = stPRPDExtInformation.iPowerFreqCycleCount;

        m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.vecPDTypeProbability.reserve(8);
        m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.vecPDTypeProbability.clear();
        for (const quint8& ucDischargeTypeProb : stPRPDExtInformation.aucPDTypeProbability)
        {
            m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.vecPDTypeProbability.push_back(ucDischargeTypeProb);
        }

        m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.qstrBGFileName = stPRPDExtInformation.qstrBGFileName;
        m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucDataJudgmentFlag = stPRPDExtInformation.eDataJudgmentFlag;
        m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.sGain = stPRPDExtInformation.sGain;
        m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucSyncSource = stPRPDExtInformation.eSyncSource;
        m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucSyncState = stPRPDExtInformation.ucSyncState;
        m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.fSyncFrequency = stPRPDExtInformation.fSyncFrequency;
        m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucDischargeSeverity = stPRPDExtInformation.eDischargeSeverity;
        m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucDenoisingThreshold = stPRPDExtInformation.ucDenoisingThreshold;
    }

    /************************************************
     * 函数名   : setPRPDData
     * 输入参数 :
       const PRPDData& stPRPDData: PRPDData
     * 输出参数 : NULL
     * 返回值   : void
     * 功能     : 设置PRPDData
     ************************************************/
    void PRPDSpectrum::setPRPDData(const PRPDData& stPRPDData)
    {
        m_pPRPDSpectrumPrivate->m_stPRPDDataPrivate.qbaPDSpectrumData = stPRPDData.qbaPDSpectrumData;
    }

    /************************************************
     * 函数名   : getPRPDExtInformation
     * 输入参数 : NULL
     * 输出参数 :
       PRPDExtInformation& stPRPDExtInformation: PRPDExtInformation
     * 返回值   : void
     * 功能     : 获取PRPDExtInformation
     ************************************************/
    void PRPDSpectrum::getPRPDExtInformation(PRPDExtInformation& stPRPDExtInformation)
    {
        stPRPDExtInformation.eAmpUnit = static_cast<AmpUnit>(m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucAmpUnit);
        stPRPDExtInformation.fAmpLowerLimit = m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.fAmpLowerLimit;
        stPRPDExtInformation.fAmpUpperLimit = m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.fAmpUpperLimit;
        stPRPDExtInformation.eFrequencyBand = static_cast<FrequencyBand>(m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucFrequencyBand);
        stPRPDExtInformation.fFrequencyLowerLimit = m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.fFrequencyLowerLimit;
        stPRPDExtInformation.fFequencyUpperLimit = m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.fFequencyUpperLimit;
        stPRPDExtInformation.iPhaseWindowCount = m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.iPhaseWindowCount;
        stPRPDExtInformation.iQuantizedAmplitude = m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.iQuantizedAmplitude;
        stPRPDExtInformation.iPowerFreqCycleCount = m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.iPowerFreqCycleCount;
        std::copy(m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.vecPDTypeProbability.begin(), m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.vecPDTypeProbability.end(), stPRPDExtInformation.aucPDTypeProbability);
        stPRPDExtInformation.qstrBGFileName = m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.qstrBGFileName;
        stPRPDExtInformation.eDataJudgmentFlag = static_cast<DataJudgmentFlag>(m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucDataJudgmentFlag);
        stPRPDExtInformation.sGain = m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.sGain;
        stPRPDExtInformation.eSyncSource = static_cast<SyncSource>(m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucSyncSource);
        stPRPDExtInformation.ucSyncState = m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucSyncState;
        stPRPDExtInformation.fSyncFrequency = m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.fSyncFrequency;
        stPRPDExtInformation.eDischargeSeverity = static_cast<DischargeSeverity>(m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucDischargeSeverity);
        stPRPDExtInformation.ucDenoisingThreshold = m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucDenoisingThreshold;
    }

    /************************************************
     * 函数名   : getPRPDData
     * 输入参数 : NULL
     * 输出参数 :
       PRPDData& stPRPDData: PRPDData
     * 返回值   : void
     * 功能     : 获取PRPDData
     ************************************************/
    void PRPDSpectrum::getPRPDData(PRPDData& stPRPDData)
    {
        stPRPDData.qbaPDSpectrumData = m_pPRPDSpectrumPrivate->m_stPRPDDataPrivate.qbaPDSpectrumData;
    }

    /************************************************
     * 函数名   : saveBinarySpectrumExtInfo
     * 输入参数 :
       QDataStream& out: 输出流
     * 输出参数 : NULL
     * 返回值   : bool
     * 功能     : 保存二进制可扩展信息段
     ************************************************/
    bool PRPDSpectrum::saveBinarySpectrumExtInfo(QDataStream& out)
    {
        out.device()->seek(SPECTRUM_HEADER_LENGTH);

        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipAmpUnit)out << m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucAmpUnit;
        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipAmpLowerLimit) out << m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.fAmpLowerLimit;
        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipAmpUpperLimit) out << m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.fAmpUpperLimit;
        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipFrequencyBand) out << m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucFrequencyBand;
        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipFrequencyLowerLimit) out << m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.fFrequencyLowerLimit;
        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipFequencyUpperLimit) out << m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.fFequencyUpperLimit;
        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipPhaseWindowCount) out << m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.iPhaseWindowCount;
        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipQuantizedAmplitude) out << m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.iQuantizedAmplitude;
        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipPowerFreqCycleCount) out << m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.iPowerFreqCycleCount;

        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipPDTypePR)
        {
            for (const quint8& uPDType : m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.vecPDTypeProbability)
            {
                out << uPDType;
            }
        }

        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipBGFileName) DataSpecificationUtils::convertStringToBinary(m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.qstrBGFileName, TYPE_ASCII, out, BG_FILE_NAME_LENTH);
        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipDataJudgmentFlag) out << m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucDataJudgmentFlag;
        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipGain) out << m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.sGain;
        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipSyncSource) out << m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucSyncSource;
        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipSyncState) out << m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucSyncState;
        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipSyncFrequency) out << m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.fSyncFrequency;
        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipDischargeSeverity) out << m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucDischargeSeverity;
        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipDenoisingThreshold) out << m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucDenoisingThreshold;

        DataSpecificationUtils::saveBinaryReservedData(SPECTRUM_BASE_LENGTH - out.device()->size(), out);

        return true;
    }

    /************************************************
     * 函数名   : saveXMLSpectrumExtInfo
     * 输入参数 :
       XMLDocument& xmlDocumentObj: xml文档对象
       QDomElement& element: dom元素
     * 输出参数 : NULL
     * 返回值   : bool
     * 功能     : 保存XML可扩展信息段
     ************************************************/
    bool PRPDSpectrum::saveXMLSpectrumExtInfo(XMLDocument& xmlDocumentObj, QDomElement& element)
    {
        xmlDocumentObj.beginElement(element);
        xmlDocumentObj.beginElement(STR_SPECTRUM_NODE_EXTINFORMATION);

        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipAmpUnit) xmlDocumentObj.setValue(TEXT_AMP_UNIT, QString::number(m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucAmpUnit));
        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipAmpLowerLimit) xmlDocumentObj.setValue(TEXT_AMP_MIN, QString::number(m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.fAmpLowerLimit, 'f', 1));
        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipAmpUpperLimit) xmlDocumentObj.setValue(TEXT_AMP_MAX, QString::number(m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.fAmpUpperLimit, 'f', 1));
        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipFrequencyBand) xmlDocumentObj.setValue(TEXT_BAND_WIDTH, QString::number(m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucFrequencyBand));
        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipFrequencyLowerLimit) xmlDocumentObj.setValue(TEXT_FRQ_MIN, QString::number(m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.fFrequencyLowerLimit, 'f', 1));
        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipFequencyUpperLimit) xmlDocumentObj.setValue(TEXT_FRQ_MAX, QString::number(m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.fFequencyUpperLimit, 'f', 1));
        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipPhaseWindowCount) xmlDocumentObj.setValue(TEXT_PHASE_INTVL_COUNT, QString::number(m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.iPhaseWindowCount));
        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipQuantizedAmplitude) xmlDocumentObj.setValue(TEXT_QUANTY_AMP, QString::number(m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.iQuantizedAmplitude));
        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipPowerFreqCycleCount) xmlDocumentObj.setValue(TEXT_PFRECYCLE_COUNT, QString::number(m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.iPowerFreqCycleCount));
        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipPDTypePR) xmlDocumentObj.setValue(TEXT_PD_TYPE_PR, DataSpecificationUtils::dischargeTypeProbabilityVector2QString(m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.vecPDTypeProbability));
        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipBGFileName) xmlDocumentObj.setValue(TEXT_BG_FILE_NAME, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.qstrBGFileName);
        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipDataJudgmentFlag) xmlDocumentObj.setValue(TEXT_EFFECIVE_SIGN, QString::number(m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucDataJudgmentFlag));
        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipGain) xmlDocumentObj.setValue(TEXT_GAIN, QString::number(m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.sGain));
        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipSyncSource) xmlDocumentObj.setValue(TEXT_SYNC_SOURCE, QString::number(m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucSyncSource));
        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipSyncState) xmlDocumentObj.setValue(TEXT_SYNC_STATE, QString::number(m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucSyncState));
        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipSyncFrequency) xmlDocumentObj.setValue(TEXT_SYNC_FREQ, QString::number(m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.fSyncFrequency, 'f', 1));
        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipDischargeSeverity) xmlDocumentObj.setValue(TEXT_DISCHARGE_SEVERITY, QString::number(m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucDischargeSeverity));
        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipDenoisingThreshold) xmlDocumentObj.setValue(TEXT_DENOISING_THRESHOLD, QString::number(m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucDenoisingThreshold));

        return true;
    }

    /************************************************
     * 函数名   : saveJSONSpectrumExtInfo
     * 输入参数 :
       rapidjson::Document::AllocatorType& alloc:
       rapidjson::Value& jsonValue: json数据
     * 输出参数 : NULL
     * 返回值   : bool
     * 功能     : 保存JSON可扩展信息段
     ************************************************/
    bool PRPDSpectrum::saveJSONSpectrumExtInfo(rapidjson::Document::AllocatorType& alloc, rapidjson::Value& jsonValue)
    {
        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipAmpUnit) saveJSONField(m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucAmpUnit, TEXT_AMP_UNIT, alloc, jsonValue);
        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipAmpLowerLimit) saveJSONField(m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.fAmpLowerLimit, TEXT_AMP_MIN, alloc, jsonValue);
        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipAmpUpperLimit) saveJSONField(m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.fAmpUpperLimit, TEXT_AMP_MAX, alloc, jsonValue);
        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipFrequencyBand) saveJSONField(m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucFrequencyBand, TEXT_BAND_WIDTH, alloc, jsonValue);
        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipFrequencyLowerLimit) saveJSONField(m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.fFrequencyLowerLimit, TEXT_FRQ_MIN, alloc, jsonValue);
        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipFequencyUpperLimit) saveJSONField(m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.fFequencyUpperLimit, TEXT_FRQ_MAX, alloc, jsonValue);
        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipPhaseWindowCount) saveJSONField(m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.iPhaseWindowCount, TEXT_PHASE_INTVL_COUNT, alloc, jsonValue);
        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipQuantizedAmplitude) saveJSONField(m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.iQuantizedAmplitude, TEXT_QUANTY_AMP, alloc, jsonValue);
        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipPowerFreqCycleCount) saveJSONField(m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.iPowerFreqCycleCount, TEXT_PFRECYCLE_COUNT, alloc, jsonValue);
        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipPDTypePR) saveJSONField(m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.vecPDTypeProbability, TEXT_PD_TYPE_PR, alloc, jsonValue);
        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipBGFileName) saveJSONField(m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.qstrBGFileName, TEXT_BG_FILE_NAME, alloc, jsonValue);
        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipDataJudgmentFlag) saveJSONField(m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucDataJudgmentFlag, TEXT_EFFECIVE_SIGN, alloc, jsonValue);
        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipGain) saveJSONField(m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.sGain, TEXT_GAIN, alloc, jsonValue);
        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipSyncSource) saveJSONField(m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucSyncSource, TEXT_SYNC_SOURCE, alloc, jsonValue);
        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipSyncState) saveJSONField(m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucSyncState, TEXT_SYNC_STATE, alloc, jsonValue);
        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipSyncFrequency) saveJSONField(m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.fSyncFrequency, TEXT_SYNC_FREQ, alloc, jsonValue);
        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipDischargeSeverity) saveJSONField(m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucDischargeSeverity, TEXT_DISCHARGE_SEVERITY, alloc, jsonValue);
        if (!m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipDenoisingThreshold) saveJSONField(m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucDenoisingThreshold, TEXT_DENOISING_THRESHOLD, alloc, jsonValue);

        return true;
    }

    /************************************************
     * 函数名   : saveBinarySpectrumData
     * 输入参数 :
       QDataStream& out: 输出流
     * 输出参数 : NULL
     * 返回值   : bool
     * 功能     : 保存二进制图谱数据段
     ************************************************/
    bool PRPDSpectrum::saveBinarySpectrumData(QDataStream& out)
    {
        if(dataCount() <= 0)
        {
            return false;
        }

        out.device()->seek(SPECTRUM_BASE_LENGTH);

        DataSpecificationUtils::saveBinaryPointerData(out, storageDataType(), m_pPRPDSpectrumPrivate->m_stPRPDDataPrivate.qbaPDSpectrumData.data(), dataCount());

        return true;
    }

    /************************************************
     * 函数名   : saveXMLSpectrumData
     * 输入参数 :
       XMLDocument& xmlDocumentObj: xml文档对象
       QDomElement& element: dom元素
     * 输出参数 : NULL
     * 返回值   : bool
     * 功能     : 保存XML图谱数据段
     ************************************************/
    bool PRPDSpectrum::saveXMLSpectrumData(XMLDocument& xmlDocumentObj, QDomElement& element)
    {
        xmlDocumentObj.beginElement(element);
        xmlDocumentObj.beginElement(STR_SPECTRUM_NODE_DATA);

        QString strData = m_pPRPDSpectrumPrivate->m_stPRPDDataPrivate.qbaPDSpectrumData.toBase64();
        xmlDocumentObj.setValue( STR_SPECTRUM_NODE_DATA, strData );

        return true;
    }

    /************************************************
     * 函数名   : saveJSONSpectrumData
     * 输入参数 :
       rapidjson::Document::AllocatorType& alloc:
       rapidjson::Value& jsonValue: json数据
     * 输出参数 : NULL
     * 返回值   : bool
     * 功能     : 保存JSON图谱数据段
     ************************************************/
    bool PRPDSpectrum::saveJSONSpectrumData(rapidjson::Document::AllocatorType& alloc, rapidjson::Value& jsonValue)
    {
        if (!m_pPRPDSpectrumPrivate->m_stPRPDDataPrivate.bSkipPDSpectrumData) saveJSONField(m_pPRPDSpectrumPrivate->m_stPRPDDataPrivate.qbaPDSpectrumData, STR_SPECTRUM_NODE_DATA, alloc, jsonValue);
        return true;
    }

    /************************************************
     * 函数名   : parseBinarySpectrumExtInfo
     * 输入参数 :
       QDataStream& in: 输入流
     * 输出参数 : NULL
     * 返回值   : bool
     * 功能     : 解析二进制可扩展信息段
     ************************************************/
    bool PRPDSpectrum::parseBinarySpectrumExtInfo(QDataStream& in)
    {
        if (!in.device()->seek(SPECTRUM_HEADER_LENGTH))
        {
            qDebug() << "PRPDSpectrum::parseBinarySpectrumExtInfo failed";
            return false;
        }

        parseBinaryField(in, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipAmpUnit, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucAmpUnit, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasAmpUnit);
        parseBinaryField(in, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipAmpLowerLimit, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.fAmpLowerLimit, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasAmpLowerLimit);
        parseBinaryField(in, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipAmpUpperLimit, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.fAmpUpperLimit, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasAmpUpperLimit);
        parseBinaryField(in, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipFrequencyBand, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucFrequencyBand, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasFrequencyBand);
        parseBinaryField(in, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipFrequencyLowerLimit, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.fFrequencyLowerLimit, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasFrequencyLowerLimit);
        parseBinaryField(in, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipFequencyUpperLimit, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.fFequencyUpperLimit, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasFequencyUpperLimit);
        parseBinaryField(in, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipPhaseWindowCount, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.iPhaseWindowCount, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasPhaseWindowCount);
        parseBinaryField(in, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipQuantizedAmplitude, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.iQuantizedAmplitude, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasQuantizedAmplitude);
        parseBinaryField(in, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipPowerFreqCycleCount, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.iPowerFreqCycleCount, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasPowerFreqCycleCount);
        parseBinaryField(in, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipPDTypePR, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.vecPDTypeProbability, 8, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasPDTypeProbability);
        parseBinaryField(in, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipBGFileName, DataSpecificationGW::TYPE_ASCII, DataSpecificationGW::BG_FILE_NAME_LENTH, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.qstrBGFileName, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasBGFileName);
        parseBinaryField(in, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipDataJudgmentFlag, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucDataJudgmentFlag, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasDataJudgmentFlag);
        parseBinaryField(in, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipGain, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.sGain, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasgain);
        parseBinaryField(in, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipSyncSource, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucSyncSource, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasSyncSource);
        parseBinaryField(in, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipSyncState, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucSyncState, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasSyncState);
        parseBinaryField(in, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipSyncFrequency, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.fSyncFrequency, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasSyncFrequency);
        parseBinaryField(in, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipDischargeSeverity, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucDischargeSeverity, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasDischargeSeverity);
        parseBinaryField(in, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bSkipDenoisingThreshold, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucDenoisingThreshold, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasDenoisingThreshold);

        return in.status() == QDataStream::Ok;
    }

    /************************************************
     * 函数名   : parseXMLSpectrumExtInfo
     * 输入参数 :
       XMLDocument& xmlDocumentObj: xml文档对象
     * 输出参数 : NULL
     * 返回值   : bool
     * 功能     : 解析XML可扩展信息段
     ************************************************/
    bool PRPDSpectrum::parseXMLSpectrumExtInfo(XMLDocument& xmlDocumentObj)
    {
        xmlDocumentObj.beginElement(spectrumName());
        xmlDocumentObj.beginElement(STR_SPECTRUM_NODE_EXTINFORMATION);

        parseXMLField(xmlDocumentObj, TEXT_AMP_UNIT, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucAmpUnit, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasAmpUnit);
        parseXMLField(xmlDocumentObj, TEXT_AMP_MIN, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.fAmpLowerLimit, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasAmpLowerLimit);
        parseXMLField(xmlDocumentObj, TEXT_AMP_MAX, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.fAmpUpperLimit, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasAmpUpperLimit);
        parseXMLField(xmlDocumentObj, TEXT_BAND_WIDTH, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucFrequencyBand, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasFrequencyBand);
        parseXMLField(xmlDocumentObj, TEXT_FRQ_MIN, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.fFrequencyLowerLimit, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasFrequencyLowerLimit);
        parseXMLField(xmlDocumentObj, TEXT_FRQ_MAX, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.fFequencyUpperLimit, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasFequencyUpperLimit);
        parseXMLField(xmlDocumentObj, TEXT_PHASE_INTVL_COUNT, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.iPhaseWindowCount, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasPhaseWindowCount);
        parseXMLField(xmlDocumentObj, TEXT_QUANTY_AMP, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.iQuantizedAmplitude, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasQuantizedAmplitude);
        parseXMLField(xmlDocumentObj, TEXT_PFRECYCLE_COUNT, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.iPowerFreqCycleCount, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasPowerFreqCycleCount);
        parseXMLField(xmlDocumentObj, TEXT_PD_TYPE_PR, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.vecPDTypeProbability, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasPDTypeProbability);
        parseXMLField(xmlDocumentObj, TEXT_BG_FILE_NAME, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.qstrBGFileName, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasBGFileName);
        parseXMLField(xmlDocumentObj, TEXT_EFFECIVE_SIGN, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucDataJudgmentFlag, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasDataJudgmentFlag);
        parseXMLField(xmlDocumentObj, TEXT_GAIN, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.sGain, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasgain);
        parseXMLField(xmlDocumentObj, TEXT_SYNC_SOURCE, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucSyncSource, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasSyncSource);
        parseXMLField(xmlDocumentObj, TEXT_SYNC_STATE, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucSyncState, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasSyncState);
        parseXMLField(xmlDocumentObj, TEXT_SYNC_FREQ, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.fSyncFrequency, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasSyncFrequency);
        parseXMLField(xmlDocumentObj, TEXT_DISCHARGE_SEVERITY, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucDischargeSeverity, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasDischargeSeverity);
        parseXMLField(xmlDocumentObj, TEXT_DENOISING_THRESHOLD, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucDenoisingThreshold, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasDenoisingThreshold);

        xmlDocumentObj.endElement();
        xmlDocumentObj.endElement();

        return true;
    }

    /************************************************
     * 函数名   : parseJSONSpectrumExtInfo
     * 输入参数 :
       const rapidjson::Value& jsonValue: json数据
     * 输出参数 : NULL
     * 返回值   : bool
     * 功能     : 解析JSON可扩展信息段
     ************************************************/
    bool PRPDSpectrum::parseJSONSpectrumExtInfo(const rapidjson::Value& jsonValue)
    {
        parseJSONField(jsonValue, TEXT_AMP_UNIT, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucAmpUnit, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasAmpUnit);
        parseJSONField(jsonValue, TEXT_AMP_MIN, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.fAmpLowerLimit, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasAmpLowerLimit);
        parseJSONField(jsonValue, TEXT_AMP_MAX, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.fAmpUpperLimit, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasAmpUpperLimit);
        parseJSONField(jsonValue, TEXT_BAND_WIDTH, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucFrequencyBand, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasFrequencyBand);
        parseJSONField(jsonValue, TEXT_FRQ_MIN, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.fFrequencyLowerLimit, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasFrequencyLowerLimit);
        parseJSONField(jsonValue, TEXT_FRQ_MAX, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.fFequencyUpperLimit, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasFequencyUpperLimit);
        parseJSONField(jsonValue, TEXT_PHASE_INTVL_COUNT, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.iPhaseWindowCount, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasPhaseWindowCount);
        parseJSONField(jsonValue, TEXT_QUANTY_AMP, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.iQuantizedAmplitude, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasQuantizedAmplitude);
        parseJSONField(jsonValue, TEXT_PFRECYCLE_COUNT, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.iPowerFreqCycleCount, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasPowerFreqCycleCount);
        parseJSONField(jsonValue, TEXT_PD_TYPE_PR, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.vecPDTypeProbability, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasPDTypeProbability);
        parseJSONField(jsonValue, TEXT_BG_FILE_NAME, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.qstrBGFileName, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasBGFileName);
        parseJSONField(jsonValue, TEXT_EFFECIVE_SIGN, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucDataJudgmentFlag, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasDataJudgmentFlag);
        parseJSONField(jsonValue, TEXT_GAIN, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.sGain, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasgain);
        parseJSONField(jsonValue, TEXT_SYNC_SOURCE, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucSyncSource, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasSyncSource);
        parseJSONField(jsonValue, TEXT_SYNC_STATE, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucSyncState, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasSyncState);
        parseJSONField(jsonValue, TEXT_SYNC_FREQ, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.fSyncFrequency, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasSyncFrequency);
        parseJSONField(jsonValue, TEXT_DISCHARGE_SEVERITY, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucDischargeSeverity, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasDischargeSeverity);
        parseJSONField(jsonValue, TEXT_DENOISING_THRESHOLD, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.ucDenoisingThreshold, m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.bHasDenoisingThreshold);

        return true;
    }

    /************************************************
     * 函数名   : parseBinarySpectrumData
     * 输入参数 :
       QDataStream& in: 输入流
     * 输出参数 : NULL
     * 返回值   : bool
     * 功能     : 解析二进制图谱数据段
     ************************************************/
    bool PRPDSpectrum::parseBinarySpectrumData(QDataStream& in)
    {
        if (!in.device()->seek(SPECTRUM_BASE_LENGTH))
        {
            qDebug() << "PRPDSpectrum::parseBinarySpectrumData failed";
            return false;
        }

        DataSpecificationUtils::parseBinaryPointerData(in, storageDataType(), m_pPRPDSpectrumPrivate->m_stPRPDDataPrivate.qbaPDSpectrumData, dataCount());

        return in.status() == QDataStream::Ok;
    }

    /************************************************
     * 函数名   : parseXMLSpectrumData
     * 输入参数 :
       XMLDocument& xmlDocumentObj: xml文档对象
     * 输出参数 : NULL
     * 返回值   : bool
     * 功能     : 解析XML图谱数据段
     ************************************************/
    bool PRPDSpectrum::parseXMLSpectrumData(XMLDocument& xmlDocumentObj)
    {
        xmlDocumentObj.beginElement(spectrumName());
        xmlDocumentObj.beginElement(STR_SPECTRUM_NODE_DATA);

        m_pPRPDSpectrumPrivate->m_stPRPDDataPrivate.qbaPDSpectrumData = QByteArray::fromBase64(xmlDocumentObj.value(STR_SPECTRUM_NODE_DATA).toLatin1());

        xmlDocumentObj.endElement();
        xmlDocumentObj.endElement();

        return true;
    }

    /************************************************
     * 函数名   : parseJSONSpectrumData
     * 输入参数 :
       const rapidjson::Value& jsonValue: json数据
     * 输出参数 : NULL
     * 返回值   : bool
     * 功能     : 解析JSON图谱数据段
     ************************************************/
    bool PRPDSpectrum::parseJSONSpectrumData(const rapidjson::Value& jsonValue)
    {
        parseJSONField(jsonValue, STR_SPECTRUM_NODE_DATA, m_pPRPDSpectrumPrivate->m_stPRPDDataPrivate.qbaPDSpectrumData, m_pPRPDSpectrumPrivate->m_stPRPDDataPrivate.bHasPDSpectrumData);

        return true;
    }

    int PRPDSpectrum::dataCount()
    {
        return m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.iPhaseWindowCount * m_pPRPDSpectrumPrivate->m_stPRPDExtInformationPrivate.iQuantizedAmplitude;
    }
}
